package com.zhou.common.operator.log.web.req;

import com.zhou.common.operator.log.core.model.OperateLogInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

@Data
public class OperateLogRecordRequest {
    private Long id;

    @ApiModelProperty(value = "操作类型(non:未知,add:添加,modify:修改,audit:审核,delete:删除,query:查询,export:导出,login:登录,logout:退出,operation:操作,batch_operation:批量操作)", position = 1)
    private String action;

    @ApiModelProperty(value = "操作资源", position = 2)
    private String resource;

    @ApiModelProperty(value = "业务id", position = 3)
    private String businessId;

    @ApiModelProperty(value = "用户id", position = 4)
    private String userId;

    @ApiModelProperty(value = "用户名", position = 5)
    private String userName;

    @ApiModelProperty(value = "用户所属部门", position = 6)
    private String orgName;

    @ApiModelProperty(value = "用户所属部门id", position = 7)
    private String orgId;

    @ApiModelProperty(value = "浏览器", position = 8)
    private String browser;

    @ApiModelProperty(value = "浏览器版本", position = 9)
    private String browserVersion;

    @ApiModelProperty(value = "操作系统", position = 9)
    private String os;

    @ApiModelProperty(value = "请求来源ip", position = 10)
    private String clientIp;

    @ApiModelProperty(value = "服务端来源ip", position = 11)
    private String serverIp;

    @ApiModelProperty(value = "备注", position = 12)
    private String remark;

    @ApiModelProperty(value = "操作系统", position = 13)
    private String operatingSystem;

    @ApiModelProperty(value = "操作说明", position = 14)
    private String operatingInstruction;

    @ApiModelProperty(value = "操作类型", position = 15)
    private String operatingType;

    @ApiModelProperty(value = "操作模块", position = 16)
    private String operatingModule;

    @ApiModelProperty(value = "用户电话", position = 17)
    private String userPhone;

    @ApiModelProperty(value = "mac地址", position = 18)
    private String macAddress;

    public OperateLogRecordRequest convertTo(OperateLogInfo info) {
        BeanUtils.copyProperties(info, this);
        BeanUtils.copyProperties(info.getClientInfo(), this);
        BeanUtils.copyProperties(info.getPrincipal(), this);
        BeanUtils.copyProperties(info.getPayloadInfo(), this);
        return this;
    }
}
